package offertest.singleton;

/**
 * @ClassName Eager
 * @Description 饿汉模式单例实现 - 类加载时立即创建实例
 * @Author ZJX
 * @Date 2025/4/10 12:10
 * @Version 1.0
 **/
public class Eager {
    // 私有静态实例，类加载时初始化
    private static final Eager instance = new Eager();

    // 私有构造方法，防止外部实例化
    private Eager() {
        // 防止通过反射创建实例
        if (instance != null) {
            throw new RuntimeException("Instance already exists!");
        }
    }

    // 提供全局访问点
    public static Eager getInstance() {
        return instance;
    }
}